package com.atguigu.gmall.web.all.service.impl;

import com.atguigu.gmall.common.cache.GmallCache;
import com.atguigu.gmall.feign.product.CategoryFeignClient;
import com.atguigu.gmall.model.vo.IndexCategoryVo;
import com.atguigu.gmall.web.all.service.IndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author dyq
 * @description
 * @data 28/1/2022
 */
@Service
public class IndexServiceImpl implements IndexService {

    final static String cachePrefix = "index:category:";

    @Autowired
    CategoryFeignClient categoryFeignClient;

    @GmallCache(
            cacheKeyExpr = cachePrefix + "#{#method.getName()}"
            ,ttl = 1000*60*24*5
            ,enableBloom = false)
    @Override
    public List<IndexCategoryVo> getAllCategory() {
        List<IndexCategoryVo> allCategoryForIndexHtml = categoryFeignClient.getAllCategoryForIndexHtml();
        return allCategoryForIndexHtml;
    }
}
